package design_pattern.momento.test1;

/**
 * Created by WeiDingKuo on 2017/10/27 14:29
 * <p>
 * 备忘录模式--白盒模式
 * <p>
 * 备忘录中存储的内容为public类型，对所有外部对象公开
 */
public class Test {
    public static void main(String[] args) {
        Orignator orignator = new Orignator();
        CareTaker careTaker = new CareTaker();

        orignator.setName("张三");
        System.out.println(orignator.getName());
        careTaker.saveMomento(orignator.createMomento());

        orignator.setName("李四");
        System.out.println(orignator.getName());
        orignator.restoreMoment(careTaker.retrieveMomento());
        System.out.println(orignator.getName());
    }
}
